<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>简单计算器</title>
    <script>
        function calculate() {
            // 获取输入框的值
            var num1 = parseFloat(document.getElementById('num1').value);
            var num2 = parseFloat(document.getElementById('num2').value);
            var operator = document.getElementById('operator').value;
            var result;

            // 根据选择的运算符进行计算
            switch(operator) {
                case '+':
                    result = num1 + num2;
                    break;
                case '-':
                    result = num1 - num2;
                    break;
                case '*':
                    result = num1 * num2;
                    break;
                case '/':
                    result = num1 / num2;
                    break;
                default:
                    result = '无效的运算符';
            }

            // 显示结果
            document.getElementById('result').value = result;
        }
    </script>
</head>
<body>
    <h1>简单计算器</h1>
    <input type="text" id="num1" placeholder="输入第一个数字">
    <select id="operator">
        <option value="+">+</option>
        <option value="-">-</option>
        <option value="*">*</option>
        <option value="/">/</option>
    </select>
    <input type="text" id="num2" placeholder="输入第二个数字">
    <button onclick="calculate()">=</button>
    <input type="text" id="result" readonly>
</body>
</html>